package cn.xm.basic.config;

import cn.xm.basic.exception.BusinessException;
import cn.xm.basic.result.AjaxResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public AjaxResult BusinessExceptionHandler (BusinessException be) {
        be.printStackTrace();
        return AjaxResult.me().fail(be.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public AjaxResult ExceptionHandler (Exception e) {
        e.printStackTrace();
        return AjaxResult.me().fail(e.getMessage());
    }

}
